#!/bin/bash

function copy_lib() {
    src_path="${1}"
    dest_path="${2}"
    libs="$(ldd ${src_path} | awk '{if ($3 != "") print $3}')"
    # -p使已存在的目录不报错
    mkdir -p ${dest_path}
    # -L追踪软连接, -r递归复制
    cp -Lrp ${libs} ${dest_path} 
}
copy_lib "./file/build/file_server" "./file/libs" 
copy_lib "./friend/build/friend_server" "./friend/libs" 
copy_lib "./gateway/build/gateway_server" "./gateway/libs" 
copy_lib "./message/build/message_server" "./message/libs" 
copy_lib "./speech/build/speech_server" "./speech/libs" 
copy_lib "./transmit/build/transmit_server" "./transmit/libs" 
copy_lib "./user/build/user_server" "./user/libs" 
